Add request ID tracking to token validation for support correlation - #6821
Conversation
Tag every call to /api/v1/authenticate/me with a client-generated X-Request-ID header and quote it in the (now visible) warning/error when validation fails, so intermittent auth failures can be correlated with control-plane logs. Expose the id via get_auth_request_id() for downstream packages (e.g. reflex-enterprise) to include in their own error messages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2
Merging this PR will not alter performance
Comparing Footnotes
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Greptile SummaryAdds request-ID correlation to hosting token validation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/reflex-hosting-cli/src/reflex_cli/utils/exceptions.py | Adds request-aware validation and access-denied exception types while retaining ValueError compatibility for denied tokens. |
| packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py | Generates, transmits, tracks, and reports request IDs throughout token validation failure handling. |
| tests/units/reflex_cli/utils/test_hosting.py | Covers request-ID uniqueness, header transmission, warning output, access-denied output, and exception metadata. |
| packages/reflex-hosting-cli/news/6821.feature.md | Documents request-ID correlation for failed token validations. |
Reviews (3): Last reviewed commit: "Carry request id on token validation exc..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Address review: the process-global last-request-id could misreport under concurrent validations. validate_token now raises TokenValidationError / TokenAccessDeniedError (backward compatible with Exception / ValueError) carrying the request id of their own request, and validate_token_with_retries prefers that over the global. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2
Type of change
Description
This PR adds request ID tracking to token validation requests to enable support teams to correlate failed authentications with server-side logs.
Changes:
New
get_auth_request_id()function inhosting.py: Returns the request ID from the most recent token validation request, allowing callers to retrieve it for support correlation.Enhanced
validate_token()function:uuid.uuid4().hex) for each validation requestX-Request-IDheader to the control planeImproved
validate_token_with_retries()error handling:Comprehensive test coverage:
test_validate_token_sends_request_id_header: Verifies each validation request carries a fresh request ID headertest_validate_token_with_retries_warns_with_request_id: Confirms failed validations surface the request ID in warningstest_validate_token_with_retries_access_denied_reports_request_id: Validates access denied errors include the request IDTesting
Checklist
https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2
Greptile Summary
Adds per-request authentication correlation IDs.
X-Request-IDheader.Confidence Score: 5/5
The PR appears safe to merge with no actionable defects identified.
The synchronous token-validation path assigns the request ID before making the HTTP request, uses that same ID in the request header, and surfaces it on each reachable failure path.
Important Files Changed
Reviews (1): Last reviewed commit: "Send X-Request-ID with token validation ..." | Re-trigger Greptile